package j5039.whcm.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import j5039.whcm.common.utils.PageUtils;
import j5039.whcm.common.utils.Query;

import j5039.whcm.product.dao.BrandDao;
import j5039.whcm.product.entity.BrandEntity;
import j5039.whcm.product.service.BrandService;


@Service("brandService")
public class BrandServiceImpl extends ServiceImpl<BrandDao, BrandEntity> implements BrandService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        LambdaQueryWrapper<BrandEntity> wrapper = new LambdaQueryWrapper<>();
        if (params.containsKey("key")&&params.get("key")!=null&&params.get("key").toString()!=""){
            Object key = params.get("key");
            wrapper.like(BrandEntity::getName,key)
                    .or().like(BrandEntity::getDescript,key)
                    .or().eq(BrandEntity::getFirstLetter,key);
        }
        IPage<BrandEntity> page = this.page(
                new Query<BrandEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}